<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>酒店详情</title>
<!-- 此文件为了显示Demo样式，项目中不需要引入 -->
   <link href="__PUBLIC__/assets/css/bs3/dpl.css" rel="stylesheet">
    <link href="__PUBLIC__/assets/css/bs3/bui.css" rel="stylesheet">
</head>
<body>
  <div class="demo-content">
    
<!-- 搜索页 ================================================== -->
    <div class="row" style="margin-top:24px">
      <div class="span24">
        <form id="searchForm" class="form-horizontal" tabindex="0" style="outline: none;">
          <div class="row">
            <div class="control-group span8">
              <label class="control-label">房间名称：</label>
              <div class="controls">
                <input type="text" name="room_name" class="control-text">
              </div>
            </div>
            <div class="form-actions span5">
              <button id="btnSearch" type="submit" class="button button-primary">搜索</button>
            </div>
          </div>
        </form>
      </div>
    </div> 
    <div class="search-grid-container">
      <div id="grid">
    </div>
    <div class="demo-content">
    <form class="form-horizontal" action="{:U('Hotel/room_set_handle')}" method="post" enctype="multipart/form-data">
        <div id="a" class="row" style="margin-top:24px">
          <div class="control-group span8">
            <label class="control-label">房间名称：</label>
            <div class="controls">
              <input name="title" data-tip='{"text":"例:总统套房","iconCls":"icon icon-home"}'  type="text" class="input-normal control-text">
              <input type="hidden" name="room_id">
            </div>
          </div>
        </div>
        <div class="row">
            <div class="control-group span8">
            <label class="control-label">房间数量：</label>
            <div class="controls">
              <input name="num"  data-tip='{"text":"剩余数量","iconCls":"icon icon-user"}'  type="text" class="input-normal control-text">
            </div>
            </div>
            <div class="control-group span8">
                <label class="control-label">房间类型：</label>
                <div class="controls">
                     <select name="cat_id" class="input-normal">
                         <foreach name="data" item='v'>
                             <option value="{$v.cat_id}">{$v.title}</option>
                         </foreach>
                    </select>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="control-group span8">
            <label class="control-label">房间大小：</label>
            <div class="controls">
              <input name="area"  data-tip='{"text":"供应商编码","iconCls":"icon icon-user"}'  type="text" class="input-normal control-text">cm<sup>2
            </div>
            </div>
            <div class="control-group span8">
            <label class="control-label">床规格：</label>
            <div class="controls">
              <input name="bed_standard"  data-tip='{"text":"供应商编码","iconCls":"icon icon-user"}'  type="text" class="input-normal control-text">
            </div>
            </div>
        </div>
        <div class="row">
            <div class="control-group span8">
            <label class="control-label">原价：</label>
            <div class="controls">
              <input name="price"  data-tip='{"text":"供应商编码","iconCls":"icon icon-user"}'  type="text" class="input-normal control-text">元
            </div>
            </div>
            <div class="control-group span8">
            <label class="control-label">优惠价：</label>
            <div class="controls">
              <input name="cprice"  data-tip='{"text":"供应商编码","iconCls":"icon icon-user"}'  type="text" class="input-normal control-text">元
            </div>
            </div>
            <div class="control-group span8">
            <label class="control-label">会员价：</label>
            <div class="controls">
              <input name="mprice"  data-tip='{"text":"供应商编码","iconCls":"icon icon-user"}'  type="text" class="input-normal control-text">元
            </div>
            </div>
            </div>
            <div class="row">
                <div class="control-group span8">
            <label class="control-label">获得积分：</label>
            <div class="controls">
              <input name="score"  data-tip='{"text":"剩余数量","iconCls":"icon icon-user"}'  type="text" class="input-normal control-text">
            </div>
            </div>
            <div class="control-group span8">
                <label class="control-label">是否启用：</label>
                <div class="controls">
                     <select name="enabled" class="input-normal"> 
                        <option value="1">已启用</option>
                        <option value="0">已禁用</option>
                    </select>
                </div>
            </div>
            </div>
        <div class="row">
          <div class="control-group span15">
            <label class="control-label">商品图片：</label>
            <div class="controls">
              <input type="file" name="img">
            </div>
          </div>
        </div>
            <div class="row">
                <div class="control-group span8">
            <label class="control-label">详情介绍：</label>
                </div>
            </div>
        <!-- 加载编辑器的容器 -->
        <script style="margin-left:48px" id="container" name="content" type="text/plain">
            
        </script>
        <div class="row form-actions actions-bar">
            <div class="span13 offset3 ">
              <button name="save" type="submit" class="button button-primary">保存</button>
              <button name="reset" type="button" class="button">重置</button>
            </div>
        </div>
    </form>
    <!-- 配置文件 -->
    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.js"></script>
    <script src="__PUBLIC__/assets/js/jquery-1.8.1.min.js"></script>
  <script src="__PUBLIC__/assets/js/bui.js"></script>
    <script src="__PUBLIC__/ueditor/ueditor.parse.js"></script>
    <!-- 实例化编辑器 -->
    <script type="text/javascript">
        var ue = UE.getEditor('container',{
            toolbars:[
                ['undo','redo','bold','indent','italic','underline','strikethrough','fontfamily','fontsize','paragraph','simpleupload','forecolor','inserttable','insertrow','insertcol','splittorows','splittocols','deletecaption','inserttitle','mergecells','deletetable','edittable','edittd','cleardoc']
            ],
            autoHeightEnabled: false,
            autoFloatEnabled: false,
            initialFrameWidth:750,
            initialFrameHeight:200,
            UEDITOR_HOME_URL:"__PUBLIC__/ueditor/",
            imageUrl:"{:U('Hotel/upload')}",
            imagePath:"__ROOT__/Public/image/",
            autoClearinitialContent:false,
            WordCount:false,
            elementPathEnabled:false,
            autoFloatEnabled:false,
            textarea:'content'
        });
    </script>
</div>
   <script src="__PUBLIC__/assets/js/jquery-1.8.1.min.js"></script>
   <script src="__PUBLIC__/assets/js/bui-min.js"></script>
    <script type="text/javascript">
        var Grid = BUI.Grid,
          Store = BUI.Data.Store,
          columns = [
            { title: '房间Id',width: 100,  sortable: false, dataIndex: 'room_id'},
            { title: '房间名称',width: 200,  sortable: false, dataIndex: 'title'},
            { title: '房间数量',width: 100,  sortable: true, dataIndex: 'num'},
            { title: '前台价格',width: 100,  sortable: true, dataIndex: 'price'},
            { title: '优惠价',width: 100,  sortable: true, dataIndex: 'cprice'},
            { title: '会员价',width: 100,  sortable: true, dataIndex: 'mprice'},
            { title: '添加时间',width: 150,  sortable: true, dataIndex: 'addtime'},
            { title: '操作', width: 300, dataIndex: 'g',renderer:function(value,obj){
              return '<span class="grid-command" onclick="eidit('+obj.room_id+')">编辑</span>';
            }}
          ];
        var
         store = new Store({
            url : "{:U('Hotel/room_load')}",
            autoLoad:true,
            pageSize:5
          }),
          grid = new Grid.Grid({
            render:'#grid',
            loadMask: true,
            forceFit:true,
            columns : columns,
            store: store,
            plugins : [Grid.Plugins.CheckSelection,Grid.Plugins.AutoFit], //勾选插件、自适应宽度插件
            // 底部工具栏
            tbar:{
             items:[{
                    btnCls : 'button button-primary button-small',
                    text:'删除',
                    handler : function(){
                      remove();
                    }
                }
                ]
            },
            // 顶部工具栏
            bbar : {
              //items 也可以在此配置
              // pagingBar:表明包含分页栏
              pagingBar:true
            }
          });
        grid.render();
        //创建表单，表单中的日历，不需要单独初始化
        var form = new BUI.Form.HForm({
          srcNode : '#searchForm'
        }).render();
 
        form.on('beforesubmit',function(ev) {
          //序列化成对象
          var obj = form.serializeToObject();
          obj.start = 0; //返回第一页
          store.load(obj);
          return false; 
        });
        function eidit(id){
          $("html,body").animate({scrollTop:$("#a").offset().top},800);
          //location.href="{:U('room_add_show')}";
          $.post("{:U('Hotel/room_detail_load')}",{room_id:id},function(result){
            eval("value="+result);
            $('[name=title]').val(value.title);
            $('[name=room_id]').val(value.room_id);
            $('[name=num]').val(value.num);
            $('[name=cat_id]').val(value.cat_id);
            $('[name=area]').val(value.area);
            $('[name=bed_standard]').val(value.bed_standard); 
            $('[name=price]').val(value.price);
            $('[name=cprice]').val(value.cprice);
            $('[name=mprice]').val(value.mprice);
            $('[name=score]').val(value.score);
            $('[name=enabled]').val(value.enabled);
            $('[name=title]').val(value.title);
            ue.ready(function() {
            ue.setContent(value.propertise);
             });
          })
          store.load();
        }
        function remove(){
          var selections = grid.getSelection(),
            ids = BUI.Array.map(selections,function (item) {
              return item.room_id;
            });
            $.post("{:U('Hotel/room_del_handle')}",{ids:ids},function(result){
              eval("value="+result);
              if(value.code=="0000"){
                alert(value.message);
              }else{
                alert(value.message);
              }
            })
            store.load();
        }
    </script>
<!-- script end -->
  </div>
</body>
</html>       